home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / BZIP2 / 980205 / bzip / Patch < prev    next >
Text File  |  1998-02-05  |  7KB  |  246 lines

  1. --- /tmp/bzip2-0.1pl2/bzip2.c    Sat Aug 30 00:32:15 1997
  2. +++ /mnt/adfs/Hacking/bzip/c/bzip2    Sat Jan 17 10:57:48 1998
  3. @@ -1,4 +1,3 @@
  4. -
  5.  /*-----------------------------------------------------------*/
  6.  /*--- A block-sorting, lossless compressor        bzip2.c ---*/
  7.  /*-----------------------------------------------------------*/
  8. @@ -94,16 +93,20 @@
  9.    Generic 32-bit Unix.
  10.    Also works on 64-bit Unix boxes.
  11.  --*/
  12. -#define BZ_UNIX      1
  13. +#define BZ_UNIX        0
  14.  
  15.  /*--
  16.    Win32, as seen by Jacob Navia's excellent
  17.    port of (Chris Fraser & David Hanson)'s excellent
  18.    lcc compiler.
  19.  --*/
  20. -#define BZ_LCCWIN32  0
  21. +#define BZ_LCCWIN32    0
  22.  
  23. +/*--
  24. +  Acorn's RISC OS (currently requires unixlib & gcc)
  25. +--*/
  26.  
  27. +#define BZ_RISCOS    1
  28.  
  29.  /*---------------------------------------------*/
  30.  /*--
  31. @@ -225,6 +228,48 @@
  32.  
  33.  #endif
  34.  
  35. +#if BZ_RISCOS
  36. +   #define BZ_FILETYPE 0x16E
  37. +
  38. +   #include <sys/types.h>
  39. +   #include <stdio.h>        /* required by tmpnam() */
  40. +   #include <sys/os.h>        /* required by os_file() */
  41. +   #include <utime.h>
  42. +   #include <unistd.h>        /* can i narrow this down & remove it? */
  43. +   #include <malloc.h>
  44. +   #include <sys/stat.h>
  45. +   #include <sys/times.h>
  46. +
  47. +   #define Int32   int
  48. +   #define UInt32  unsigned int
  49. +   #define Char    char
  50. +   #define UChar   unsigned char
  51. +   #define Int16   short
  52. +   #define UInt16  unsigned short
  53. +
  54. +   #define PATH_SEP    '.'
  55. +   #define MY_LSTAT    lstat
  56. +   #define MY_S_IFREG  S_ISREG
  57. +   #define MY_STAT     stat
  58. +
  59. +   #define APPEND_FILESPEC(root, name) \
  60. +      root=snocString((root), (name))
  61. +
  62. +   #define SET_BINARY_MODE(fd) /**/
  63. +
  64. +   /*--
  65. +      You should try very hard to persuade your C compiler
  66. +      to inline the bits marked INLINE.  Otherwise bzip2 will
  67. +      run rather slowly.  gcc version 2.x is recommended.
  68. +   --*/
  69. +   #ifdef __GNUC__
  70. +      #define INLINE   inline
  71. +      #define NORETURN __attribute__ ((noreturn))
  72. +   #else
  73. +      #define INLINE   /**/
  74. +      #define NORETURN /**/
  75. +   #endif
  76. +#endif
  77.  
  78.  /*---------------------------------------------*/
  79.  /*--
  80. @@ -3276,10 +3321,16 @@
  81.  /*---------------------------------------------*/
  82.  Bool fileExists ( Char* name )
  83.  {
  84. +#ifdef BZ_RISCOS
  85. +   int regs[6];
  86. +   os_file( 17, name, regs );
  87. +   return regs[0] & 1;
  88. +#else
  89.     FILE *tmp   = fopen ( name, "rb" );
  90.     Bool exists = (tmp != NULL);
  91.     if (tmp != NULL) fclose ( tmp );
  92.     return exists;
  93. +#endif
  94.  }
  95.  
  96.  
  97. @@ -3316,6 +3367,10 @@
  98.     ERROR_IF_NOT_ZERO ( retVal );
  99.     retVal = utime ( dstName, &uTimBuf );
  100.     ERROR_IF_NOT_ZERO ( retVal );
  101. +   #elif BZ_RISCOS
  102. +   int regs [6];
  103. +   os_file(17, srcName, regs);
  104. +   os_file(1, dstName, regs);
  105.     #endif
  106.  }
  107.  
  108. @@ -3323,6 +3378,11 @@
  109.  /*---------------------------------------------*/
  110.  Bool endsInBz2 ( Char* name )
  111.  {
  112. +#ifdef BZ_RISCOS
  113. +   int regs[6];
  114. +   os_file(17, name, regs);
  115. +   return (((regs[2] & 0x000fff00) >> 8) == BZ_FILETYPE);
  116. +#else
  117.     Int32 n = strlen ( name );
  118.     if (n <= 4) return False;
  119.     return
  120. @@ -3330,6 +3390,7 @@
  121.         name[n-3] == 'b' &&
  122.         name[n-2] == 'z' &&
  123.         name[n-1] == '2');
  124. +#endif
  125.  }
  126.  
  127.  
  128. @@ -3354,12 +3415,19 @@
  129.  
  130.     switch (srcMode) {
  131.        case SM_I2O: strcpy ( inName, "(stdin)" );
  132. -                   strcpy ( outName, "(stdout)" ); break;
  133. +                   strcpy ( outName, "(stdout)" );
  134. +                   break;
  135.        case SM_F2F: strcpy ( inName, name );
  136. +#ifdef BZ_RISCOS
  137. +           tmpnam ( outName );
  138. +#else
  139.                     strcpy ( outName, name );
  140. -                   strcat ( outName, ".bz2" ); break;
  141. +                   strcat ( outName, ".bz2" );
  142. +#endif
  143. +           break;
  144.        case SM_F2O: strcpy ( inName, name );
  145. -                   strcpy ( outName, "(stdout)" ); break;
  146. +                   strcpy ( outName, "(stdout)" );
  147. +                   break;
  148.     }
  149.  
  150.     if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
  151. @@ -3377,11 +3445,13 @@
  152.                  progName, inName );
  153.        return;
  154.     }
  155. +#ifndef BZ_RISCOS
  156.     if ( srcMode != SM_I2O && notABogStandardFile ( inName )) {
  157.        fprintf ( stderr, "%s: Input file %s is not a normal file, skipping.\n",
  158.                  progName, inName );
  159.        return;
  160.     }
  161. +#endif
  162.     if ( srcMode == SM_F2F && fileExists ( outName ) ) {
  163.        fprintf ( stderr, "%s: Output file %s already exists, skipping.\n",
  164.                  progName, outName );
  165. @@ -3459,6 +3529,14 @@
  166.           IntNative retVal = remove ( inName );
  167.           ERROR_IF_NOT_ZERO ( retVal );
  168.        }
  169. +#ifdef BZ_RISCOS
  170. +      {
  171. +         int regs[3];
  172. +     rename( outName, inName );
  173. +     regs[2] = BZ_FILETYPE;
  174. +     os_file( 18, inName, regs);
  175. +      }
  176. +#endif
  177.     }
  178.  }
  179.  
  180. @@ -3475,14 +3553,20 @@
  181.  
  182.     switch (srcMode) {
  183.        case SM_I2O: strcpy ( inName, "(stdin)" );
  184. -                   strcpy ( outName, "(stdout)" ); break;
  185. +                   strcpy ( outName, "(stdout)" );
  186. +                   break;
  187.        case SM_F2F: strcpy ( inName, name );
  188. +#ifdef BZ_RISCOS
  189. +           tmpnam( outName );
  190. +#else
  191.                     strcpy ( outName, name );
  192.                     if (endsInBz2 ( outName ))
  193.                        outName [ strlen ( outName ) - 4 ] = '\0';
  194. +#endif
  195.                     break;
  196.        case SM_F2O: strcpy ( inName, name );
  197. -                   strcpy ( outName, "(stdout)" ); break;
  198. +                   strcpy ( outName, "(stdout)" );
  199. +                   break;
  200.     }
  201.  
  202.     if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
  203. @@ -3501,11 +3585,13 @@
  204.                  progName, inName );
  205.        return;
  206.     }
  207. +#ifndef BZ_RISCOS
  208.     if ( srcMode != SM_I2O && notABogStandardFile ( inName )) {
  209.        fprintf ( stderr, "%s: Input file %s is not a normal file, skipping.\n",
  210.                  progName, inName );
  211.        return;
  212.     }
  213. +#endif
  214.     if ( srcMode == SM_F2F && fileExists ( outName ) ) {
  215.        fprintf ( stderr, "%s: Output file %s already exists, skipping.\n",
  216.                  progName, outName );
  217. @@ -3576,6 +3662,14 @@
  218.              IntNative retVal = remove ( inName );
  219.              ERROR_IF_NOT_ZERO ( retVal );
  220.           }
  221. +#ifdef BZ_RISCOS
  222. +     {
  223. +        int regs[3];
  224. +        rename( outName, inName );
  225. +        regs[2] = 0xffd;
  226. +        os_file( 18, inName, regs );
  227. +     }
  228. +#endif
  229.        }
  230.     } else {
  231.        if ( srcMode == SM_F2F ) {
  232. @@ -3630,11 +3724,13 @@
  233.                  progName, inName );
  234.        return;
  235.     }
  236. +#ifndef BZ_RISCOS
  237.     if ( srcMode != SM_I2O && notABogStandardFile ( inName )) {
  238.        fprintf ( stderr, "%s: Input file %s is not a normal file, skipping.\n",
  239.                  progName, inName );
  240.        return;
  241.     }
  242. +#endif
  243.  
  244.     switch ( srcMode ) {
  245.  
  246.